package com.qk.mapper;

import com.qk.dto.UserDto;
import com.qk.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {


    List<User> selectList(UserDto userDto);


    void deleteByIds(List<Integer> ids);

    void insert(User user);

    @Select("select id,username,name,phone,email,gender,status,dept_id,role_id,image,remark," +
            "create_time,update_time from user where id = #{id}")
    User getById(Integer id);

    void update(User user);

    //根据角色查询用户
    List<User> roleLabelList(String roleLabel);

    @Select("select u.*,r.label role_label from user u left join role r on u.role_id = r.id where username=#{username}")
    User selectByUsername(String username);

    //查询所有用户
    @Select("select * from user")
    List<User> allList();

    //根据部门查询用户
    @Select("select u.* from user u,dept d where u.dept_id=d.id and d.id=#{deptId}")
    List<User> getByDeptId(Integer deptId);
}
